<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>用户管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <link rel="shortcut icon" href="${path}/gui/themes/icons/logo_mini.ico" type="image/x-icon" />
</head>
<body>
<table class="easyui-datagrid" title="用户列表" id="sysAccountManage_list" iconCls="icon-data" style="display: none"
       data-options=
               "singleSelect:true,
                pagination:true,
                  pageSize:'${pageSize}',
            	  pageList:${pageList},
                 url:'${path}/sys/admin/sysAccountManagerList',
                 toolbar:'[id^=sysAccountMaTab]',
                 rownumbers:true">
    <thead>
    <tr>
        <th field="loginname" width="150">登录名</th>
        <th field="kawyiname" width="150">昵称</th>
        <th field="email" width="220">邮箱</th>
        <th data-options="field:'lockedName',width:100,align:'left',formatter:viewlocked">锁定状态</th>
        <th  data-options="field:'isdeleteName',width:100,align:'left',formatter:viewisdelete">删除状态</th>
        <th field="type" width="110">注册类型</th>
        <th field="createtime" formatter="todateTime"  width="160">注册时间</th>
    </tr>
    </thead>
</table>

<div id="sysAccountMaTab_1">
    <span class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'" onclick="addUser()">添加</span>
    <span class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-remove'" onclick="removeUser()">删除</span>
    <span class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-locked'" onclick="lockedUser()">锁定</span>
    <span class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-key'" onclick="keyUser()">解锁</span>
    <span class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-pmwd'" onclick="replacePwd()">重置密码</span>
    <span class="easyui-menubutton" data-options="menu:'#mmsas',iconCls:'icon-export'">导出</span>
</div>

<div id="sysAccountMaTab_2">


    锁定状态:
    <select id="locked_" panelHeight="auto" style="width:100px" name="locked">
        <option value="">--请选择--</option>
        <#list isLockedMap?keys as k>
            <option value="${k}">--${isLockedMap[k]}--</option>
        </#list>
    </select>
    删除状态:
    <select id="isdelete_" panelHeight="auto" style="width:100px" name="isdelete">
        <option value="">--请选择--</option>
        <#list isDeleteMap?keys as k>
            <option value="${k}">--${isDeleteMap[k]}--</option>
        </#list>
    </select>
</div>

<div id="sysAccountMaTab_3">
    登录名 <input class="easyui-textbox" type="text" name="loginName" id="loginName"/>
    昵称 <input class="easyui-textbox" type="text" name="kawyiName" id="kawyiName"/>
    邮箱 <input class="easyui-textbox" type="text" name="email" id="email"/>
   注册时间  <input class="easyui-datebox" style="width:110px" name="createTime_s" id="createTime_s" />
        - <input class="easyui-datebox" style="width:110px" name="createTime_e" id="createTime_e" />
         <span class="easyui-linkbutton" iconCls="icon-search" id="sysAccountManage_list_search">查询 </span>
</div>

<div id="mmsas" style="width:150px;">
    <div data-options="iconCls:'icon-excel03'">Excel03</div>
    <div data-options="iconCls:'icon-excel10'">Excel10</div>
    <div data-options="iconCls:'icon-pdf'">PDF</div>
    <div data-options="iconCls:'icon-dbf'">DBF</div>
</div>

<script type="text/javascript">
    $(function(){
        $("#sysAccountManage_list_search").click(function(){
            var locked=$("#locked_").find("option:selected").val();
            var isdelete=$("#isdelete_").find("option:selected").val();
            var loginName = $("#loginName").val();
            var kawyiName = $("#kawyiName").val();
            var emailt = $("#email").val();
            var createTime_s = $('#createTime_s').datebox('getValue');
            var createTime_e = $('#createTime_e').datebox('getValue');
            $("#sysAccountManage_list").datagrid('load',{
                loginName : loginName,
                email : emailt,
                locked : locked,
                isdelete : isdelete,
                kawyiName : kawyiName,
                createTime_s : createTime_s,
                createTime_e : createTime_e
            })
        });
    });

    function viewlocked(val,row){
        if(val=="锁定"){
            return "<font color='red'>"+val+"</font>";
        }else{
            return val;
        }
    }

    function viewisdelete(val,row){
        if(val=="删除"){
            return "<font color='red'>"+val+"</font>";
        }else{
            return val;
        }
    }

    /***
     * 解锁
     * */
    function keyUser(){
        var row = $('#sysAccountManage_list').datagrid('getSelected');
        if(row){
            $.messager.confirm('提示','您确定要锁定用户'+row.loginname+"吗？",function(r){
                if(r){
                    $.post('${path}/sys/sysAccountLocked',{id:row.id,type:'K'},function(data){
                        if (data.mta==1){
                            $('#sysAccountManage_list').datagrid('reload');
                            $.messager.alert('提示',data.msg,'info');
                        }else{
                            $.messager.alert('提示',data.msg,'error');
                        }
                        $('#sysAccount_list1').datagrid('reload');
                    },'json');
                }
            });
        }else{
            $.messager.alert('提示','请选择一条记录!','warning');
        }
    }

    /***
     * 锁定
     * */
    function lockedUser(){
        var row = $('#sysAccountManage_list').datagrid('getSelected');
        if(row){
            $.messager.confirm('提示','您确定要锁定用户'+row.loginname+"吗？",function(r){
                if(r){
                    $.post('${path}/sys/sysAccountLocked',{id:row.id,type:'L'},function(data){
                        if (data.mta==1){
                            $('#sysAccountManage_list').datagrid('reload');
                            $.messager.alert('提示',data.msg,'info');
                        }else{
                            $.messager.alert('提示',data.msg,'error');
                        }
                        $('#sysAccount_list1').datagrid('reload');
                    },'json');
                }
            });
        }else{
            $.messager.alert('提示','请选择一条记录!','warning');
        }
    }

    /***
     * 删除
     * */
    function removeUser(){
        var row = $('#sysAccountManage_list').datagrid('getSelected');
        if(row){
            $.messager.confirm('提示','您确定要删除用户'+row.loginname+"吗？",function(r){
                if(r){
                    $.post('${path}/sys/sysAccountDelete',{id:row.id},function(data){
                        if (data.mta==1){
                            $('#sysAccountManage_list').datagrid('reload');
                            $.messager.alert('提示',data.msg,'info');
                        }else{
                            $.messager.alert('提示',data.msg,'error');
                        }
                        $('#sysAccount_list1').datagrid('reload');
                    },'json');
                }
            });
        }else{
            $.messager.alert('提示','请选择一条记录!','warning');
        }
    }


/***
 * 重置密码
 */
function replacePwd(){
	 var row = $('#sysAccountManage_list').datagrid('getSelected');
     if(row){
         $.messager.confirm('提示','您确定要重置用户'+row.loginname+"的密码为888888吗？",function(r){
             if(r){
                 $.post('${path}/sys/sysaccountReplace',{id:row.id},function(data){
                     if (data.mta==1){
                         $('#sysAccountManage_list').datagrid('reload');
                          $.messager.alert('提示',data.msg,'info');
                     }else{
                         $.messager.alert('提示',data.msg,'error');
                     }
                     $('#sysAccount_list1').datagrid('reload');
                 },'json');
             }
         });
     }else{
         $.messager.alert('提示','请选择一条记录!','warning');
     }
}
</script>
</body>
</html>